#ifndef KEY_H
#define KEY_H

#include <QList>
#include <math.h>

template<int n>
struct Key
{
    int level;
    QList<int> params;
    Key(int a_level, QList<int> a_params): level(a_level), params(a_params){}

    Key(int a_level, QList<double> list): level(a_level)
    {
        int temp;
        for(int i=0; i<n; i++)
        {
            temp = static_cast<int>(floor(list[i] * (1<<level)));
            temp = (temp == (1<<level))?(temp - 1):temp;
            params.append(temp);
        }
    }
};

template<int n>
inline bool operator<(Key<n> left, Key<n> right)
{
    if(left.level < right.level)
    {
        return(true);
    }
    if(left.level > right.level)
    {
        return(false);
    }

    for(int i=0; i<n; i++)
    {
        if(left.params[i] < right.params[i])
        {
            return(true);
        }
        if(left.params[i] > right.params[i])
        {
            return(false);
        }
    }
    return(false);
}

#endif // KEY_H
